package com.jackrain.nea.omslocal.task;

import com.jackrain.nea.config.PropertiesConf;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * Description: 自动任务主类
 * Created with IntelliJ IDEA.
 * User: cs
 * Date: 2017/4/13
 * Time: 10:29
 */
@Component
@Slf4j
@Order(99)
public class TaskConfig implements CommandLineRunner {

    @Autowired
    private AutoUpdateQty autoUpdateQty;
    @Autowired
    private AutoHeartBeat autoHeartBeat;
    @Autowired
    private AutoChangeQtyStatus autoChangeQtyStatus;
    @Autowired
    private AutoUpOrderStatus autoUpOrderStatus;
    @Autowired
    private AutoLogistcSend autoLogistcSend;
    @Autowired
    private AutoExchangeOrder autoExchangeOrder;
    @Autowired
    private AutoQiMenWmsDeliceryOrderCreat autoQiMenDeliceryOrderCreat;
    @Autowired
    private AutoQiMenDrpDeliceryOrderCreat autoQiMenDrpDeliceryOrderCreat;
    @Autowired
    private AutoQiMenPosDeliceryOrderCreat autoQiMenPosDeliceryOrderCreat;
    @Autowired
    private AutoSendOrderCreat autoSendOrderCreat;
    @Autowired
    private PropertiesConf pconf;
    @Autowired
    private AutoQiMenEventProduce autoQiMenEventProduce;


    @Override
    public void run(String... strings) throws Exception {

        // 执行同步库存自动任务
        autoUpdateQty.getScheduledExecutorA();
        // autoUpdateQty.getScheduledExecutorB();
        //执行更改超时库存状态与异常数据
        autoChangeQtyStatus.getScheduledExecutor();
        // 执行心跳任务
        autoHeartBeat.getScheduledExecutor();
        // 淘宝同步订单发货状态
        autoLogistcSend.getScheduledExecutorA();
        // 同步订单发货状态,已发送且超时的数据
        autoLogistcSend.getScheduledExecutorB();
        // 淘宝换货功能,卖家确认收货
        autoExchangeOrder.getScheduledExecutor();

        if (pconf.getPropertyBoolean("ons.startjdtask")) {
            // 京东发货任务
            autoSendOrderCreat.getScheduledExecutorSendA();
            // 京东同步库存
            autoUpdateQty.getScheduledExecutorC();
        }

        //  奇门任务
        if (pconf.getPropertyBoolean("ons.startqimentask")) {
            autoQiMenDeliceryOrderCreat.getScheduledExecutorSendA();
            autoQiMenDeliceryOrderCreat.getScheduledExecutorSendAgainA();
            autoQiMenPosDeliceryOrderCreat.getScheduledExecutorSendA();
            autoQiMenDrpDeliceryOrderCreat.getScheduledExecutorSendA();
        }

        //全渠道回流任务
        if (pconf.getPropertyBoolean("ons.startQimenOrderProduce")){
            autoQiMenEventProduce.getScheduledExecutorSendA();
        }

        if(pconf.getPropertyBoolean("ons.startVopqty")){
            //OXO增量库存同步与共享库存增量同步
            autoUpdateQty.getScheduledExecutorD();
        }




        //压测,自动上传同步订单状态 订单同步任务
        // autoUpOrderStatus.getScheduledExecutor();
        // 云仓订单同步任务（双11，大屏数据展示）
        //autoPushOrder.getScheduledExecutor();

    }

}
